// index.js文件
Component({
  data: {
    active: 0,
    list: [
      {
        "url": "/pages/home/home",
        "icon": "wap-home-o",
        "text": "首页"
      },
      {
        "url": "/pages/test2/test2",
        "icon": "shop-o",
        "text": "商场"
      },
      {
        "url": "/pages/order/order",
        "icon": "balance-list-o",
        "text": "订单"
      },
      {
        "url": "/pages/user/user",
        "icon": "user-circle-o",
        "text": "我的"
      }
    ]
    },
    methods: {
     onChange(e) {
        console.log(e,'e')
        wx.switchTab({
          url: this.data.list[e.detail].url
        });
        this.setData({ active: e.detail });
     },
     init() {
         const page = getCurrentPages().pop();
         this.setData({
        　  active: this.data.list.findIndex(item => item.url === `/${page.route}`)
         });
        },
        //扫码
        scan(){
          wx.scanCode({
            success (res) {
              console.log(res)
            }
          })
        }
     }
});